package org.han.action;

import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Result;

import org.apache.struts2.convention.annotation.Action;
import org.han.beans.PageBean;
import org.han.service.ILoginBiz;
import org.han.util.JsonUtil;
import org.han.vo.PageVo;

public class PageAction implements com.opensymphony.xwork2.Action {
	
	private PageVo pv;
	private ILoginBiz biz;
	public ILoginBiz getBiz() {
		return biz;
	}

	public void setBiz(ILoginBiz biz) {
		this.biz = biz;
	}

	public PageVo getPv() {
		return pv;
	}

	public void setPv(PageVo pv) {
		this.pv = pv;
	}

	@Override
	@Action(value = "/page", results = {
			@Result(name = "success", location = "/page.jsp")}, className = "pageAction")
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		HttpServletResponse response=ServletActionContext.getResponse();
		HttpServletRequest request=ServletActionContext.getRequest();
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();

		String str=biz.getPageBean(pv.getPageIndex(), pv.getPageSize());
		out.print(str);
		out.close();
		return null;
	}

}
